Skip to content

feat(badge): add recipe and tokens#31043

Merged
thetaPC merged 98 commits intoionic-modularfrom
FW-6837
May 2, 2026
Merged

feat(badge): add recipe and tokens#31043
thetaPC merged 98 commits intoionic-modularfrom
FW-6837

Conversation

@thetaPC
Copy link
Copy Markdown
Contributor

@thetaPC thetaPC commented Mar 27, 2026

Issue number: internal


What is the current behavior?

Component styles for ion-badge are fragmented across multiple files (ios, md). Developers were restricted to those themes and how those themes structured the logic and styles.

What is the new behavior?

  • Unified Style Architecture: Combined theme-specific styling into a single badge.scss file that consumes CSS variables, ensuring a single source of truth for component logic.
  • Defined TypeScript Interface: Added badge.interfaces.ts
  • Updated Test Page: Updated the badge test page to be simple since new test pages with more in depth use cases were created
  • Added Test Pages: Badge has multiple use cases based on which component it's slotted into. Test pages were added due to that.

Does this introduce a breaking change?

  • Yes
  • No

This PR introduces a breaking change to how IonBadge is styled. Existing manual CSS overrides targeting internal badge structures or old token names will no longer work due to the shift to thew new token hierarchy and a unified base SCSS file.

Migration Path:

  1. Token Updates: Update any custom theme configurations to match the new nested structure.

  2. CSS Overrides: Ensure selectors align with the new slotted element logic and variable names (e.g., --ion-badge-hue-bold-default-background).

--background should no longer be used. Setting the value, Badge.hue.bold.background, within the tokens file should be used to change the background for the bold hue. Setting the value, Badge.hue.subtle.background, within the tokens file should be used to change the background for the subtle hue.

  1. Theme classes: Remove any instances that target the theme classes: badge.md

Other information

This PR significantly improves the developer experience for theming. By moving logic into default.tokens.ts and away from hardcoded SCSS functions, designers and developers can now override styles (like the size on a slotted avatar) purely through token configuration.

@vercel
Copy link
Copy Markdown

vercel Bot commented Mar 27, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
ionic-framework Ready Ready Preview, Comment May 1, 2026 1:50pm

Request Review

Comment on lines -59 to -61
:host ::slotted(ion-badge[vertical]:not(:empty)) {
@include globals.padding(2px);
}
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed this completely because based on MD3, the padding should always be consistent regardless of the host component.


/**
* @virtualProp {"ios" | "md"} mode - The mode determines the platform behaviors of the component.
* @virtualProp {"ios" | "md" | "ionic"} theme - The theme determines the visual appearance of the component.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forgot to remove this in the first iteration of review.

Copy link
Copy Markdown
Member

@brandyscarney brandyscarney left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of my feedback is related to styles and tests. 👍

Comment thread core/src/components/button/test/badge/index.html
Comment thread core/src/components/avatar/test/badge/avatar.e2e.ts
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same issue here with badges being cut off. Apologies if you already added this to the tab bar and told me. 😅

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It still looks cut off to me but we can fix it on tab bar:

image

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I misunderstood, thinking you meant that they cut off of the screen. Yes, I plan to revisit this when we migrate tab button.

Comment thread core/src/components/button/test/badge/index.html
Copy link
Copy Markdown
Member

@ShaneK ShaneK left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an intense PR and you've put in an amazing amount of great work! I only found a few actual issues and a couple nits (apart from Brandy's stuff)

Comment thread core/src/components/badge/badge.scss Outdated
Comment thread core/src/components/button/test/badge/button.e2e.ts
Comment thread core/src/components/tab-button/test/badge/tab-button.e2e.ts
Comment thread core/src/components/avatar/avatar.tsx
Comment thread core/src/components/tab-button/tab-button.tsx
Comment thread core/src/utils/badge-position.ts
Comment thread core/src/utils/badge-position.ts
Copy link
Copy Markdown
Member

@ShaneK ShaneK left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of my issues have been resolved, all that's left is Brandy's stuff! Great work!

Copy link
Copy Markdown
Member

@brandyscarney brandyscarney left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work on this!! Really love the updates to get us closer to native. 🙌 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

package: angular @ionic/angular package package: core @ionic/core package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants